package com.example.myaccount.util;

import android.util.Log;

import com.example.myaccount.constant.MyConst;

import java.util.ArrayList;

public class MathUtil {

    public static  ArrayList<String> spiltNumberStr(java.lang.String numberStr){
        ArrayList<String> numbers = new ArrayList<>();
        String[] strsPlus = numberStr.split("\\+");
        for(int i=0;i<strsPlus.length;i++){
            String[] strMinus = strsPlus[i].split("-");
            for(int j=0;j<strMinus.length;j++){
                if(j==0){
                    numbers.add(strMinus[j]);
                }else{
                    numbers.add("-"+strMinus[j]);
                }
            }
        }
        return numbers;
    }

    public static boolean isDoubleDot(String numberStr){
        if(numberStr.contains("."))
            return true;
        return false;
    }

    public static double calculateNumbers(ArrayList<String> numbers){
        double amount=0.0d;
        for(int i=0;i<numbers.size();i++){
            amount+=Double.parseDouble(numbers.get(i));
        }
        return amount;
    }
}
